import lejos.nxt.Motor;
import lejos.robotics.subsumption.Behavior;

/**
 * Moves the robot forward.
 */
public class MoveForward implements Behavior {
	private boolean suppressed = false;
	
	/**
	 * Tell the motors to move forward.
	 * Once we need to stop (suppressed), stop the motors.
	 */
	public void action() {
		suppressed = false;
		Motor.A.forward();
		Motor.B.forward();
		
		while (!suppressed)
			Thread.yield();
		
		Motor.A.stop();
		Motor.B.stop();
	}

	/* (non-Javadoc)
	 * @see lejos.robotics.subsumption.Behavior#suppress()
	 */
	public void suppress() {
		suppressed = true;
	}

	/**
	 * Always take control.
	 */
	public boolean takeControl() {
		return true;
	}
}
